package cn.siat.gene.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import cn.siat.common.security.utils.SecurityUtils;
import cn.siat.gene.domain.ProgrammeState;
import cn.siat.gene.mapper.ProgrammeStateMapper;
import cn.siat.gene.service.IProgrammeStateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import java.util.List;
import java.util.Map;

/**
 * @Description: 方案状态表
 * @Author: Administrator
 * @Date:   2022-10-22
 * @Version: V1.0
 */
@Service
public class ProgrammeStateServiceImpl extends ServiceImpl<ProgrammeStateMapper, ProgrammeState> implements IProgrammeStateService {
    @Autowired
    private ProgrammeStateMapper programmeStateMapper;
    @Override
    public Boolean checkName(String programmeName,String id) {
        QueryWrapper<ProgrammeState> wrapper = new QueryWrapper<ProgrammeState>()
                .eq("programme_name", programmeName);
        //编辑弹窗不校验本身
        if(id!=null){
            wrapper.ne("id", id);
        }
        Long count = programmeStateMapper.selectCount(wrapper);
        if(count == null || count == 0L){
            return  false;
        }
        return true;
    }

    @Override
    public Boolean programmeNumber(String programmeNumber, String id) {
        QueryWrapper<ProgrammeState> wrapper = new QueryWrapper<ProgrammeState>()
                .eq("programme_number", programmeNumber);
        //编辑弹窗不校验本身
        if(id!=null){
            wrapper.ne("id", id);
        }
        Long count = programmeStateMapper.selectCount(wrapper);
        if(count == null || count == 0L){
            return  false;
        }
        return true;
    }

    @Override
    public List<Map<String, String>> getSimpleList() {

        return programmeStateMapper.getSimpleList();
    }
}
